#ifndef __HDVB_ALLOC_LCNS_H
#define __HDVB_ALLOC_LCNS_H
/*
    libhdvbd - Library for building sophisticated DVB applications
    Copyright (C) 2012 Tony Houghton <h@realh.co.uk>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser general Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser general Public License for more details.

    You should have received a copy of the GNU Lesser general Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/* Transfers data from lcns table to services table because chanscan doesn't
 * do it for you. This ensures each service has a unique LCN, but needs
 * further help in the case of Freesat to make sure the right regional channels
 * are matched to the right LCNs.
 */

#include <glib.h>

#include <sqlite3.h>

G_BEGIN_DECLS

/* Looks up an LCN for each service and sets its value in the services table.
 * Every service given an LCN will have a unique one, but some may be left
 * unset (0).
 * region is the Freesat region code, or -1 if not supported.
 * Returns the last used lcn.
 */
int
hdvb_alloc_lcns(sqlite3 *db, int region);

/* Any services with an unset LCN (0) will be allocated with one starting from
 * the start value. Returns the last used LCN.
 */
int
hdvb_alloc_lcns_leftovers(sqlite3 *db, int start);

G_END_DECLS

#endif /* __HDVB_ALLOC_LCNS_H */
